feat(mcp): read-only getState tool (portable read-side hedge)#46
Merged
Conversation
Completes the read side started by the resources projection. MCP resources are
the correct read side but the least-supported MCP primitive (some hosts — e.g.
Cursor — are tools-only); a getState TOOL is the portable hedge that works on any
tools-capable host, including a direct Anthropic/Vercel tool projection
(research-11 §3.2, "ship both"). Directly serves reelee-web, which consumes
buildToolsList to feed Anthropic tools (not MCP).
- Pure (resources.ts): buildGetStateTool(views, opts) → a wire-safe
(app_getState default) readOnlyHint tool descriptor whose `view` param
enumerates the listed view ids; callGetState(views, args) reads the view as
errors-as-data (invalid view → isError; unknown/internal → null).
- Server: createMcpServer(registry, { views, getStateTool: true }) merges the
tool into tools/list and routes it in tools/call. Default off; requires views.
Fully backward-compatible.
- McpToolDescriptor gained an optional `annotations` field (readOnlyHint etc.);
the getState tool sets it. Command-tool projection unchanged.
- +5 tests (28 in the package); typecheck + build + workspace green.
Docs: README getState section; acture-mcp + acture-ai-assistant skills note the
shipped tool; roadmap v1.16 entry. minor changeset (1.2.0 → 1.3.0).
Claude-Session: https://claude.ai/code/session_016teVFousRsWNhiiPNpG1p9
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
Completes the AI read side started by the resources projection (#44). MCP resources are the correct read side but the least-supported MCP primitive — some hosts (e.g. Cursor) are tools-only. A
getStatetool is the portable hedge that works on any tools-capable host, including a direct Anthropic/Vercel tool projection (research-11 §3.2, "ship both").This directly serves the named consumer reelee-web, which consumes
buildToolsListto feed Anthropic tools (not MCP) — so a puregetStatedescriptor slots straight into its flow.Changes
resources.ts):buildGetStateTool(views, opts)→ a wire-safe (app_getStatedefault,^[a-zA-Z0-9_-]{1,64}$),readOnlyHinttool descriptor whoseviewparam enumerates the listed view ids;callGetState(views, args)→ errors-as-data (invalidview→isError; unknown/internal view →null).createMcpServer(registry, { views, getStateTool: true })merges the tool intotools/listand routes it intools/call. Default off; requiresviews. Backward-compatible.McpToolDescriptorgained an optionalannotationsfield (readOnlyHint/destructiveHint/idempotentHint/openWorldHint); the getState tool sets it. Command-tool projection unchanged (deriving annotations from a command side-effect class stays deferred with the confirmation-gate work).Docs
README getState section;
acture-mcp+acture-ai-assistantskills note the shipped tool; roadmap v1.16.minorchangeset (acture-mcp-server1.2.0 → 1.3.0).Still deferred
The keymap-customization helper (second v1.14 accelerator) and the
sideEffect/requiresConfirmationclosed-surface question.https://claude.ai/code/session_016teVFousRsWNhiiPNpG1p9